<template>
	<view class="container">
		<!-- 顶部栏 -->
		<view class="header">
			
			
		</view>

		<!-- 分类标签 -->
		<view class="tabs">
			<view
				v-for="(tab, idx) in tabs"
				:key="tab"
				:class="['tab', idx === activeTab ? 'active' : '']"
				@click="activeTab = idx"
			>{{ tab }}</view>
		</view>

		<!-- 活动卡片列表 -->
		<view class="activity-list">
			<view class="card" v-for="item in activities" :key="item.activityId">
				<view class="card-header">
					<image :src="item.activityImage" class="icon" />
					<text class="card-title">{{ item.activityTitle }}</text>
				</view>
				<view class="card-img-wrap">
					<image :src="item.activityImage" class="card-img" />
					<view class="date">{{ item.activityStartTime }}</view>
				</view>
				<view class="card-info">
					<text class="info-title">{{ item.activityTitle }}</text>
					<text class="price">门票：<text class="price-value">{{ item.activityPrice }}</text>元</text>
				
				</view>
			</view>
		</view>
	</view>
</template>

<script>
  	import request from '@/util/request.js';
	export default {
		data() {
			return {
				tabs: ['全部', '采摘活动', '亲子钓鱼', '露营', '农耕研学'],
				activeTab: 0,
				activities: [
					{
						activityId: 1,
						icon: 'http://121.36.197.175:19000/test/icon1.png', // 替换为实际图标路径
						title: '亲子研学报名',
						img: 'http://121.36.197.175:19000/test/act1.jpg', // 替换为实际图片路径
						date: '2025.09.28',
						price: '9.90~9.90',
						time: '2025.04.01 ~ 2025.09.28'
					},
					{
						id: 2,
						icon: 'http://121.36.197.175:19000/test/icon1.png',
						title: '采摘草莓',
						img: 'http://121.36.197.175:19000/test/act2.jpg',
						date: '2025.09.18',
						price: '',
						time: ''
					}
				]
			}
		},
		methods: {
			getActivities() {
				// 获取活动列表数据
				request({
					url: 'y-service/activity/page',
					method: 'GET',
					data: {
						current: 1,
						size: 3
					}
				}).then(res => {
					console.log(res);
					this.activities=res.data.activityList.records;
				}).catch(err => {
					console.error('获取认养项目出错', err);
				});
			}
		},
		onLoad() {
			this.getActivities();
		}
	}
</script>

<style>
	.container { background: #f7f7f7; min-height: 100vh; }
	.header { display: flex; align-items: center; justify-content: space-between; padding: 20rpx; background: #fff; }
	.back { font-size: 40rpx; }
	.title { font-size: 36rpx; font-weight: bold; }
	.right-btns { display: flex; gap: 20rpx; }
	.dot, .scan { font-size: 32rpx; }
	.tabs { display: flex; background: #fff; border-bottom: 1px solid #eee; }
	.tab { flex: 1; text-align: center; padding: 20rpx 0; color: #888; }
	.tab.active { color: #4caf50; border-bottom: 4rpx solid #4caf50; font-weight: bold; }
	.activity-list { padding: 20rpx; }
	.card { background: #fff; border-radius: 16rpx; margin-bottom: 30rpx; box-shadow: 0 2rpx 8rpx #eee; }
	.card-header { display: flex; align-items: center; padding: 20rpx; }
	.icon { width: 40rpx; height: 40rpx; margin-right: 16rpx; }
	.card-title { font-size: 32rpx; font-weight: bold; }
	.card-img-wrap { position: relative; }
	.card-img { width: 100%; height: 200rpx; object-fit: cover; border-radius: 0 0 16rpx 16rpx; }
	.date { position: absolute; right: 20rpx; top: 20rpx; background: rgba(0,0,0,0.4); color: #fff; padding: 4rpx 16rpx; border-radius: 20rpx; font-size: 24rpx; }
	.card-info { padding: 20rpx; }
	.info-title { display: block; font-size: 28rpx; margin-bottom: 8rpx; }
	.price { color: #888; }
	.price-value { color: #4caf50; font-weight: bold; }
	.time { display: block; color: #aaa; font-size: 24rpx; margin-top: 8rpx; }
</style>
